package com.heima.user.controller;

import com.heima.common.dtos.PageResult;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.admin.dtos.AdUserDto;
import com.heima.model.user.dtos.AuthDto;
import com.heima.model.user.dtos.UserAuthDto;
import com.heima.user.service.ApUserAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/auth")
public class ApUserAuthController {
    @Autowired
    private ApUserAuthService userAuthService;

    //用户服务--用户认证列表查询
    @PostMapping("/list")
    public PageResult<UserAuthDto> findByStatus(@RequestBody AuthDto dto){
        return userAuthService.findByStatus(dto);
    }

    //用户服务--认证信息审核通过
    @PostMapping("/authPass")
    public ResponseResult authPass(@RequestBody AuthDto dto){
        //修改用户验证表中的状态
        userAuthService.authUser(dto,9);
        return ResponseResult.ok();
    }
    //用户服务--认证信息审核不通过
    @PostMapping("/authFail")
    public ResponseResult authFail(@RequestBody AuthDto dto){
        //修改用户验证表中的状态
        userAuthService.authUser(dto,2);
        return ResponseResult.ok();
    }
}
